package bairui.international.model.domain.jpa;

import com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue;

/**
 *
 * (电子券赠送记录)TB_ElectronicTicketPresentRecord
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_ElectronicTicketPresentRecord#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_electronicTicketPresentRecord")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("电子券赠送记录")
@com.lianjing.sh.processing.info.annotation.InfoComment("电子券赠送记录")
public class TB_ElectronicTicketPresentRecord
 extends TBSuper_BaseIDAndTimeAndOrderValue
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<Long>,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		/** 电子券 */
		public bairui.international.model.domain.jpa.TB_ElectronicTicket getElectronicTicket();
		/** 接受赠送者 */
		public bairui.international.model.domain.jpa.TB_User getPresenteder();
		/** 赠送者 */
		public bairui.international.model.domain.jpa.TB_User getPresenter();
		/** 卡号 */
		public String getNumber();
		/** 转送次数 */
		public Integer getTransmitCount();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_ElectronicTicketPresentRecord properties(MustProperties properties) {
		this.setElectronicTicket(properties.getElectronicTicket());
		this.setPresenteder(properties.getPresenteder());
		this.setPresenter(properties.getPresenter());
		this.setNumber(properties.getNumber());
		this.setTransmitCount(properties.getTransmitCount());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_ElectronicTicketPresentRecord(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_ElectronicTicketPresentRecord properties(OptionalSingleProperties properties) {
		return this;
	}
	
	
	
	public TB_ElectronicTicketPresentRecord(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		/** 电子券 */
		public bairui.international.model.domain.jpa.TB_ElectronicTicket getElectronicTicket();
		/** 接受赠送者 */
		public bairui.international.model.domain.jpa.TB_User getPresenteder();
		/** 赠送者 */
		public bairui.international.model.domain.jpa.TB_User getPresenter();
		/** 卡号 */
		public String getNumber();
		/** 转送次数 */
		public Integer getTransmitCount();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_ElectronicTicketPresentRecord properties(CurrentMustProperties properties) {
		this.setElectronicTicket(properties.getElectronicTicket());
		this.setPresenteder(properties.getPresenteder());
		this.setPresenter(properties.getPresenter());
		this.setNumber(properties.getNumber());
		this.setTransmitCount(properties.getTransmitCount());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_ElectronicTicketPresentRecord properties(CurrentOptionalSingleProperties properties) {
		return this;
	}
	
	public TB_ElectronicTicketPresentRecord(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_ElectronicTicketPresentRecord(
		@lombok.NonNull com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean
	) {
		update(bean);
	}
	
	public TB_ElectronicTicketPresentRecord update(com.lianjing.sh.model.uml.model.data.TBSuper_BaseIDAndTimeAndOrderValue bean){
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			Integer orderValue = getOrderValue(TB_ElectronicTicketPresentRecord.this);
			if(isOverride_getOrderValue){
				TB_ElectronicTicketPresentRecord.this.setOrderValue(orderValue);
			}
	
			bairui.international.model.domain.jpa.TB_ElectronicTicket electronicTicket = getElectronicTicket(TB_ElectronicTicketPresentRecord.this);
			if(isOverride_getElectronicTicket){
				TB_ElectronicTicketPresentRecord.this.setElectronicTicket(electronicTicket);
			}
	
			bairui.international.model.domain.jpa.TB_User presenteder = getPresenteder(TB_ElectronicTicketPresentRecord.this);
			if(isOverride_getPresenteder){
				TB_ElectronicTicketPresentRecord.this.setPresenteder(presenteder);
			}
	
			bairui.international.model.domain.jpa.TB_User presenter = getPresenter(TB_ElectronicTicketPresentRecord.this);
			if(isOverride_getPresenter){
				TB_ElectronicTicketPresentRecord.this.setPresenter(presenter);
			}
	
			String number = getNumber(TB_ElectronicTicketPresentRecord.this);
			if(isOverride_getNumber){
				TB_ElectronicTicketPresentRecord.this.setNumber(number);
			}
	
			Integer transmitCount = getTransmitCount(TB_ElectronicTicketPresentRecord.this);
			if(isOverride_getTransmitCount){
				TB_ElectronicTicketPresentRecord.this.setTransmitCount(transmitCount);
			}
		}
	
		public TB_ElectronicTicketPresentRecord up(){
			return TB_ElectronicTicketPresentRecord.this;
		}
	
		/** 排序值 */
		private boolean isOverride_getOrderValue = true;
		public Integer getOrderValue(TB_ElectronicTicketPresentRecord it) throws Exception { 
			isOverride_getOrderValue = false; 
			return null;
		}
		/** 电子券 */
		private boolean isOverride_getElectronicTicket = true;
		public bairui.international.model.domain.jpa.TB_ElectronicTicket getElectronicTicket(TB_ElectronicTicketPresentRecord it) throws Exception { 
			isOverride_getElectronicTicket = false; 
			return null;
		}
		/** 接受赠送者 */
		private boolean isOverride_getPresenteder = true;
		public bairui.international.model.domain.jpa.TB_User getPresenteder(TB_ElectronicTicketPresentRecord it) throws Exception { 
			isOverride_getPresenteder = false; 
			return null;
		}
		/** 赠送者 */
		private boolean isOverride_getPresenter = true;
		public bairui.international.model.domain.jpa.TB_User getPresenter(TB_ElectronicTicketPresentRecord it) throws Exception { 
			isOverride_getPresenter = false; 
			return null;
		}
		/** 卡号 */
		private boolean isOverride_getNumber = true;
		public String getNumber(TB_ElectronicTicketPresentRecord it) throws Exception { 
			isOverride_getNumber = false; 
			return null;
		}
		/** 转送次数 */
		private boolean isOverride_getTransmitCount = true;
		public Integer getTransmitCount(TB_ElectronicTicketPresentRecord it) throws Exception { 
			isOverride_getTransmitCount = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_ElectronicTicketPresentRecord() {
	}
	
	public TB_ElectronicTicketPresentRecord(
		@lombok.NonNull Long id
	) {
		this.setId(id);
	}
	
	public TB_ElectronicTicketPresentRecord(
		@lombok.NonNull TB_ElectronicTicketPresentRecord bean
	) {
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setElectronicTicket(bean.getElectronicTicket());
		this.setPresenteder(bean.getPresenteder());
		this.setPresenter(bean.getPresenter());
		this.setNumber(bean.getNumber());
		this.setTransmitCount(bean.getTransmitCount());
	}
	
	

	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("电子券")
	@com.lianjing.sh.processing.info.annotation.InfoComment("电子券")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_ElectronicTicket electronicTicket;

	@com.lianjing.sh.model.common.annotation.Comment("接受赠送者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("接受赠送者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_User presenteder;

	@com.lianjing.sh.model.common.annotation.Comment("赠送者")
	@com.lianjing.sh.processing.info.annotation.InfoComment("赠送者")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToOne(optional=false)
	private bairui.international.model.domain.jpa.TB_User presenter;

	@com.lianjing.sh.model.common.annotation.Comment("卡号")
	@com.lianjing.sh.processing.info.annotation.InfoComment("卡号")
	@javax.persistence.Column(name="number", unique=true, nullable=false, length=32)
	private String number;

	@com.lianjing.sh.model.common.annotation.Comment("转送次数")
	@com.lianjing.sh.processing.info.annotation.InfoComment("转送次数")
	@javax.persistence.Column(name="transmitCount", nullable=false)
	private Integer transmitCount;

	/** get[电子券] */
	public bairui.international.model.domain.jpa.TB_ElectronicTicket getElectronicTicket() {
		return this.electronicTicket;
	}

	/** get[接受赠送者] */
	public bairui.international.model.domain.jpa.TB_User getPresenteder() {
		return this.presenteder;
	}

	/** get[赠送者] */
	public bairui.international.model.domain.jpa.TB_User getPresenter() {
		return this.presenter;
	}

	/** get[卡号] */
	public String getNumber() {
		return this.number;
	}

	/** get[转送次数] */
	public Integer getTransmitCount() {
		return this.transmitCount;
	}

	/** set[电子券] */
	public void setElectronicTicket(bairui.international.model.domain.jpa.TB_ElectronicTicket electronicTicket) {
		this.electronicTicket = electronicTicket;
	}

	/** set[接受赠送者] */
	public void setPresenteder(bairui.international.model.domain.jpa.TB_User presenteder) {
		this.presenteder = presenteder;
	}

	/** set[赠送者] */
	public void setPresenter(bairui.international.model.domain.jpa.TB_User presenter) {
		this.presenter = presenter;
	}

	/** set[卡号] */
	public void setNumber(String number) {
		this.number = number;
	}

	/** set[转送次数] */
	public void setTransmitCount(Integer transmitCount) {
		this.transmitCount = transmitCount;
	}

	public void assignElectronicTicket(bairui.international.model.domain.jpa.TB_ElectronicTicket electronicTicket) {
		if(null != electronicTicket){
			electronicTicket.addElectronicTicketPresentRecords(this);
		}
		this.setElectronicTicket(electronicTicket);
	}
	

	public void assignPresenteder(bairui.international.model.domain.jpa.TB_User presenteder) {
		if(null != presenteder){
			presenteder.addElectronicTicketPresentedRecords(this);
		}
		this.setPresenteder(presenteder);
	}
	

	public void assignPresenter(bairui.international.model.domain.jpa.TB_User presenter) {
		if(null != presenter){
			presenter.addElectronicTicketPresentRecords(this);
		}
		this.setPresenter(presenter);
	}
	

	
	
	

	/** take[电子券] */
	public bairui.international.model.domain.jpa.TB_ElectronicTicket takeElectronicTicket(){
		if(null == this.electronicTicket){
			this.electronicTicket = new bairui.international.model.domain.jpa.TB_ElectronicTicket();
		}
		return this.electronicTicket;
	}
	
	/** take[接受赠送者] */
	public bairui.international.model.domain.jpa.TB_User takePresenteder(){
		if(null == this.presenteder){
			this.presenteder = new bairui.international.model.domain.jpa.TB_User();
		}
		return this.presenteder;
	}
	
	/** take[赠送者] */
	public bairui.international.model.domain.jpa.TB_User takePresenter(){
		if(null == this.presenter){
			this.presenter = new bairui.international.model.domain.jpa.TB_User();
		}
		return this.presenter;
	}
	
	/** must[电子券] */
	public bairui.international.model.domain.jpa.TB_ElectronicTicket mustElectronicTicket() {
		return this.electronicTicket;
	}
	
	/** must[接受赠送者] */
	public bairui.international.model.domain.jpa.TB_User mustPresenteder() {
		return this.presenteder;
	}
	
	/** must[赠送者] */
	public bairui.international.model.domain.jpa.TB_User mustPresenter() {
		return this.presenter;
	}
	
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_ElectronicTicketPresentRecord other = (TB_ElectronicTicketPresentRecord) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		this.setCreateTime(new java.util.Date());
		this.setModifyTime(new java.util.Date());
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
		this.setModifyTime(new java.util.Date());
	}



}
